﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:clustering="clr-namespace:DeepEarth.Map.Core.Clustering"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
    xmlns:converters="clr-namespace:DeepEarth.Map.Core.Converters"
    >
        <converters:BooleanVisibilityConverter x:Key="boolVisConverter"></converters:BooleanVisibilityConverter>    
        <Style TargetType="clustering:MapItemAdorner">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="clustering:MapItemAdorner">
                    <!-- IsVisible visibility binding is effected in code because we want to bind to the actual control, not this first grid -->
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup Name="ClusterStates">
                                <vsm:VisualState x:Name="Clustered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClusterSize" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"></DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="NotClustered">                                    
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Grid x:Name="PART_IconContainer"></Grid>
                        <Grid x:Name="PART_AdditionalOverlaysContainer">
                            <Canvas x:Name="PART_OverlayContainer" Visibility="{Binding ShowDetails, Converter={StaticResource boolVisConverter}}"></Canvas>
                            <TextBlock FontSize="{Binding FontSize, ElementName=PART_ClusterSize}" Foreground="Black" Text ="{Binding Text, ElementName=PART_ClusterSize}" Visibility="{Binding Visibility, ElementName=PART_ClusterSize}">
                            <TextBlock.RenderTransform>
							    <CompositeTransform TranslateX="1" TranslateY="1"/>
						    </TextBlock.RenderTransform>
                            </TextBlock>
                            <TextBlock x:Name="PART_ClusterSize" FontSize="16" Foreground="Yellow" Text ="{Binding ClusterSize}" Visibility="{Binding IsCluster, Converter={StaticResource boolVisConverter}}"></TextBlock>
                        </Grid>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
